﻿var virualpath ="../../"
$(function () {
    var res = window.location.search;
    var resdata = res.split(",")
    if (res == "") {

    } else {
        if (resdata.length <= 1) {
            prourlid = resdata[0].split("=")[1];
        } else {
            AdminName = resdata[0].split("=")[1];
            Password = resdata[1].split("Pwd=")[1];
        }
        if (AdminName != "" && Password != "") {
            var field = {};
            field.AdminName = AdminName;
            field.EncryptPwd = Password;
            $.ajax({
                url: virualpath + '/Login/LocationSignIn',
                type: 'post',
                dataType: 'json',
                data: JSON.stringify(field),
                contentType: 'application/json',
                async: false,
                success: function (data) {
                    if (data.RspCode == 1) {
                        GetCourseinfo(prourlid);
                    }
                    if (data.RspCode == 0) {
                        location.href = "index.html"
                    }

                }
            })
        } 
    }  
    GetVideo()
})



function GetVideo() {
    $.ajax({
        url: virualpath + '/Course/GetCourseVideoList',
        type: 'Get',
        async: false,
        dataType: 'json',
        contentType: 'application/json',
        success: function (data) {
            var resultData = data
            if (resultData != undefined) {
                var Str = "";
                for (var i = 0; i < Object.keys(resultData).length; i++) {
                    //if (i<8) {
                    //    Str += '<div id="dd' + resultData[i].Id + '" class="onelist color2" onclick="CourseLocation(' + resultData[i].Id + ')"><div class="onelistin"><div class="fg_info"><div class="teaface"><img src="' + resultData[i].Course_Filepath + resultData[i].Course_VideoImg + '" /></div><p class="facetitp">' + resultData[i].Course_Name + '</p><p class="facetitp2">主讲教师：' + resultData[i].TName + '</p><span class="facetitp3">' + resultData[i].Company + '<br>' + resultData[i].Section + '</span><div class="btn_box"><a class="btn_enter">开始学习</a></div></div><div class="pic"><img src="' + resultData[i].Course_Filepath + resultData[i].Course_BackImg + '" /></div><div class="info_s"><div class="oneinfo time"><b></b>' + resultData[i].Course_Videomin + '</div><div class="oneinfo love"><b></b>' + resultData[i].Course_LikeNumber + '</div><div class="oneinfo user"><b></b>' + resultData[i].Course_BrowseNumber + '</div></div><div class="info_b"><div class="college">' + resultData[i].Company + '</div><div class="teacher"></div><div class="topic">' + resultData[i].Course_Name + '</div><div class="subject">所属课目：' + resultData[i].PName + ' </div></div></div></div>';
                    //}
                    //else {
                    //    Str += '<div style="display:none" id="dd' + resultData[i].Id + '" class="onelist color2" onclick="CourseLocation(' + resultData[i].Id + ')"><div class="onelistin"><div class="fg_info"><div class="teaface"><img src="' + resultData[i].Course_Filepath + resultData[i].Course_VideoImg + '" /></div><p class="facetitp">' + resultData[i].Course_Name + '</p><p class="facetitp2">主讲教师：' + resultData[i].TName + '</p><span class="facetitp3">' + resultData[i].Company + '<br>' + resultData[i].Section + '</span><div class="btn_box"><a class="btn_enter">开始学习</a></div></div><div class="pic"><img src="' + resultData[i].Course_Filepath + resultData[i].Course_BackImg + '" /></div><div class="info_s"><div class="oneinfo time"><b></b>' + resultData[i].Course_Videomin + '</div><div class="oneinfo love"><b></b>' + resultData[i].Course_LikeNumber + '</div><div class="oneinfo user"><b></b>' + resultData[i].Course_BrowseNumber + '</div></div><div class="info_b"><div class="college">' + resultData[i].Company + '</div><div class="teacher"></div><div class="topic">' + resultData[i].Course_Name + '</div><div class="subject">所属课目：' + resultData[i].PName + ' </div></div></div></div>';
                    //}
                       Str += '<div id="dd' + resultData[i].Id + '" class="onelist color1" onclick="CourseLocation(' + resultData[i].Id + ')"><div class="onelistin" ><div class="fg_info"><div class="teaface"><img src="' + resultData[i].Course_Filepath + resultData[i].Course_VideoImg + '" /></div><p class="facetitp">' + resultData[i].Course_Name + '</p><p class="facetitp2">主讲教师：' + resultData[i].TName + '</p><span class="facetitp3">' + resultData[i].Company + '<br>' + resultData[i].Section + '</span><div class="btn_box"><a class="btn_enter">开始学习</a></div></div><div class="pic"><img src="' + resultData[i].Course_Filepath + resultData[i].Course_BackImg + '" /></div><div class="info_s"><div class="oneinfo time"><b></b>' + resultData[i].Course_Videomin + '</div><div class="oneinfo love"><b></b>' + resultData[i].Course_LikeNumber + '</div> <div class="oneinfo user"><b></b>' + resultData[i].Course_BrowseNumber + '</div></div><div class="info_b"><div class="college">' + resultData[i].Company + '</div><div class="teacher"></div><div class="topic">' + resultData[i].Course_Name + '</div><div class="subject">所属课目：' + resultData[i].PName + '</div></div></div></div >';
                }
                
                $("#CourseVideolist").append(Str);
            }
        }
    })

    $.ajax({
        url: virualpath + '/Project/GetProjectVideoList',
        type: 'get',
        async: false,
        dataType: 'json',
        contentType: 'application/json',
        success: function (data) {
            var resultData = data;
            if (resultData != undefined) {
                var Str = "";
                for (var i = 0; i < Object.keys(resultData).length; i++) {
                        //if (i<=4) {
                        //    Str += '<div id="d' + resultData[i].Id + '" class="onelist color1" onclick="ProLocation(' + resultData[i].Id + ',' + resultData[i].Proid + ')"><div class="onelistin"><div class="fg_info"><p class="facetitp4">' + resultData[i].Pro_Name + '</p><p class="facetitp5">主讲教师：' + resultData[i].TName + '</p><p class="facetitp6">' + resultData[i].Company + resultData[i].Position + '</p><div class="btn_box"><a class="btn_enter">开始学习</a></div></div><div class="pic"><img src="' + resultData[i].Pro_Filepath + resultData[i].Pro_BackImg + '" /></div><div class="info_s"><div class="oneinfo time"><b></b>' + resultData[i].Pro_Videomin + '</div><div class="oneinfo love"><b></b>' + resultData[i].Pro_LikeNumber + '</div><div class="oneinfo user"><b></b>' + resultData[i].Pro_BrowseNumber + '</div></div><div class="info_b"><div class="college">' + resultData[i].Pro_Name + '</div><div class="teacher"></div><div class="topic">' + resultData[i].Pro_Name + '</div><div class="subject">所属课目：' + resultData[i].Pro_Name + ' </div></div></div></div>';
                        //} else {
                        //    Str += '<div style="display:none" id="d' + resultData[i].Id + '" class="onelist color1" onclick="ProLocation(' + resultData[i].Id + ',' + resultData[i].Proid + ')"><div class="onelistin"><div class="fg_info"><p class="facetitp4">' + resultData[i].Pro_Name + '</p><p class="facetitp5">主讲教师：' + resultData[i].TName + '</p><p class="facetitp6">' + resultData[i].Company + resultData[i].Position + '</p><div class="btn_box"><a class="btn_enter">开始学习</a></div></div><div class="pic"><img src="' + resultData[i].Pro_Filepath + resultData[i].Pro_BackImg + '" /></div><div class="info_s"><div class="oneinfo time"><b></b>' + resultData[i].Pro_Videomin + '</div><div class="oneinfo love"><b></b>' + resultData[i].Pro_LikeNumber + '</div><div class="oneinfo user"><b></b>' + resultData[i].Pro_BrowseNumber + '</div></div><div class="info_b"><div class="college">' + resultData[i].Pro_Name + '</div><div class="teacher"></div><div class="topic">' + resultData[i].Pro_Name + '</div><div class="subject">所属课目：' + resultData[i].Pro_Name + ' </div></div></div></div>';
                    //}
                    Str += ' <div id="d' + resultData[i].Id + '" class="onelist color1" onclick="ProLocation(' + resultData[i].Id + ',' + resultData[i].Proid + ')">< div class="onelistin" ><div class="fg_info"><div class="teaface"><img src="course2/images/kpt2_1.2.jpg" /></div><p class="facetitp">血涂片检查</p><p class="facetitp2">主讲教师：' + resultData[i].TName + '</p><span class="facetitp3">' + resultData[i].Company + resultData[i].Position + '</span><div class="btn_box"><a class="btn_enter">开始学习</a></div></div><div class="pic"><img src="' + resultData[i].Pro_Filepath + resultData[i].Pro_BackImg + '" /></div><div class="info_s"><div class="oneinfo time"><b></b>' + resultData[i].Pro_Videomin + '</div><div class="oneinfo love"><b></b>' + resultData[i].Pro_LikeNumber + '</div><div class="oneinfo user"><b></b>' + resultData[i].Pro_BrowseNumber + '</div></div><div class="info_b"><div class="college">' + resultData[i].Pro_Name + '</div> <div class="teacher"></div><div class="topic">' + resultData[i].Pro_Name + '</div><div class="subject">所属课目：' + resultData[i].Pro_Name + '</div></div></div></div >';
                            
                        
                    
                }

                $("#ProVideolist").append(Str);
            }
        }
    })

    setTimeout(function () {

   

    var _content = []; //临时存储li循环内容
    var ldm1 = {
        _default: 8, //默认显示图片个数
        _loading: 4,  //每次点击按钮后加载的个数
        init: function () {
            var lis = $(".loadmore1 .hidden .onelist");
            $(".loadmore1 ul.list").html("");
            for (var n = 0; n < ldm1._default; n++) {
                lis.eq(n).appendTo(".loadmore1 ul.list");
            }
            $(".loadmore1 ul.list .onelist").each(function () {
                $(this).attr('src', $(this).attr('realSrc'));
            })
            for (var i = ldm1._default; i < lis.length; i++) {
                _content.push(lis.eq(i));
            }
            $(".loadmore1 .hidden").html("");
        },
        loadMore: function () {
            var mLis = $(".loadmore1 ul.list .onelist").length;
            for (var i = 0; i < ldm1._loading; i++) {
                var target = _content.shift();
                if (!target) {
                    $('.more.kwlg1').html("<p>全部加载完毕...</p>");
                    break;
                }
                $(".loadmore1 ul.list").append(target);
                $(".loadmore1 ul.list .onelist").eq(mLis + i).each(function () {
                    $(this).attr('src', $(this).attr('realSrc'));
                });
            }
        }
    }
    ldm1.init();

    var _content2 = []; //临时存储li循环内容
    var ldm2 = {
        _default: 8, //默认显示图片个数
        _loading: 4,  //每次点击按钮后加载的个数
        init: function () {
            var lis = $(".loadmore2 .hidden .onelist");
            $(".loadmore2 ul.list").html("");
            for (var n = 0; n < ldm2._default; n++) {
                lis.eq(n).appendTo(".loadmore2 ul.list");
            }
            $(".loadmore2 ul.list .onelist").each(function () {
                $(this).attr('src', $(this).attr('realSrc'));
            })
            for (var i = ldm2._default; i < lis.length; i++) {
                _content2.push(lis.eq(i));
            }
            $(".loadmore2 .hidden").html("");
        },
        loadMore: function () {
            var mLis = $(".loadmore2 ul.list .onelist").length;
            for (var i = 0; i < ldm2._loading; i++) {
                var target = _content2.shift();
                if (!target) {
                    $('.more.kwlg2').html("<p>全部加载完毕...</p>");
                    break;
                }
                $(".loadmore2 ul.list").append(target);
                $(".loadmore2 ul.list .onelist").eq(mLis + i).each(function () {
                    $(this).attr('src', $(this).attr('realSrc'));
                });
            }
        }
    }
    ldm2.init();
    }, 2000)
}

function ProLocation(id) {
    location.href = "Project.html?id=" + id + "";
}

function CourseLocation(id, Proid) {
    location.href = "Course.html?id=" + id + ",Proid=" + Proid + "";
}


